<?php
        class QDateTimeC extends QControl {
            protected $Cal;
            protected $Time;
            protected $objParentObject;

                    // We want to override the constructor in order to setup the subcontrols
            public function __construct($objParentObject, $strControlId = null) {
                // First, call the parent to do most of the basic setup
                try {
                    parent::__construct($objParentObject, $strControlId);
                } catch (QCallerException $objExc) {
                    $objExc->IncrementOffset();
                    throw $objExc;
                }
                // Define the Controls
                $this->objParentObject=$objParentObject;

                $this->Cal = new QCalendarPopup($this);

                
                $this->Time = new QDateTimePicker($this);
                $this->Time->DateTimePickerType = QDateTimePickerType::Time;

            }
            public function ParsePostData() {}


            public function Validate() { return true;
            }
            protected function GetControlHtml() {
                $strCal = $this->Cal->Render(false);
                $strTime = $this->Time->Render(false);
                return sprintf('%s %s'
                        ,$strCal,$strTime);

            }

        // And our public getter/setters
        public function __get($strName) {
            switch ($strName) {
                case 'DateTime':
                    $datet= new QDateTime();

                    $dtDate = $this->Cal->DateTime;
                    $dtTime = $this->Time->DateTime;

                    $datet->setDate( $dtDate->__get("Year"), $dtDate->__get("Month"), $dtDate->__get("Day") );
                    $datet->setTime( $dtTime->__get("Hour"), $dtTime->__get("Minute"),0 );

                    return $datet;
                default:
                    try {
                        return parent::__get($strName);
                    } catch (QCallerException $objExc) {
                        $objExc->IncrementOffset();
                        throw $objExc;
                    }
            }
        }

        public function __set($strName, $mixValue) {
            $bolRt = true;
            try {
                switch ($strName) {
                        case 'DateTime':
                             //if (gettype($strName) == ""
                             if ($mixValue == null){
                                 $mixValue = new QDateTime("Now");

                             }
                             $dtT = new QDateTime();
                             $dtT->setDate($mixValue->__get("Year"), $mixValue->__get("Month"), $mixValue->__get("Day"));
                             $dtT->setTime($mixValue->__get("Hour"), $mixValue->__get("Minute"), 0);
                             $this->Cal->DateTime = $dtT;
                             $this->Time->DateTime = $dtT;

                        return $bolRt;
                    default:
                        return (parent::__set($strName, $mixValue));
                }
            } catch (QCallerException $objExc) {
                $objExc->IncrementOffset();
                throw $objExc;
            }
        }


        }

?>
